<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../../include/tag.jsp"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>权限管理</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <link rel="stylesheet" href="${ctx}/css/ui/system/role_list.css">
    <%@include file="../../include/commonFile.jsp"%>
</head><body>
<!--头部-->
<%@include file="../../include/header.jsp"%>
<div class="index-outside">
    <%@include file="../../include/sidebar.jsp"%>
    <!--内容-->
    <section>
        <div class="section-main">
            <div class="layui-tab-item layui-show">
                <div class="layui-tab layui-tab-brief" lay-filter="root">
                    <ul class="layui-tab-title">
                        <c:forEach var="root" items="${sysPrivileges}">
                            <li data-id="${root.id}" <c:if test="${root.id == sysPrivilege.parentId}">class="layui-this"</c:if>>${root.name}</li>
                        </c:forEach>
                    </ul>
                    <div class="layui-tab-content">
                        <form class="layui-form" action="${ctx}/system/privilege/list.do" id="myForm" method="post">
                            <input type="hidden" name="pageNo" id="pageNo" />
                            <input type="hidden" name="parentId" value="${sysPrivilege.parentId}" />
                            <%--<div class="f-search-bar">
                                <div class="search-container">
                                    <ul class="search-form-content">
                                        <li class="form-item-inline">
                                            <label class="search-form-lable">名称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="name" autocomplete="off" class="layui-input" value="${sysPrivilege.name}" placeholder="请输入查询名称">
                                            </div>
                                        </li>
                                        <li class="form-item-inline">
                                            <label class="search-form-lable">编码</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="code" autocomplete="off" class="layui-input" value="${sysPrivilege.code}" placeholder="请输入查询编码">
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">类型</label>
                                            <div class="layui-input-inline">
                                                <select name="type">
                                                    <option value="">全部</option>
                                                    <c:forEach items="${types}" var="type">
                                                        <option value="${type.key}" <c:if test="${sysPrivilege.type == type.key}">selected</c:if>>${type.value}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                        </li>
                                        <li  class="form-item-inline">
                                            <div class="sub-btns">
                                                <a class="layui-btn layui-btn-danger" href="javascript:submitFunction('#myForm')">查询</a>
                                                <a class="layui-btn layui-btn-normal" href="javascript:resetFunction('#myForm')">重置</a>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </div>--%>
                        </form>
                        <div class="my-act-list-content">
                            <ul id="view">
                                <table class="layui-table">
                                    <colgroup>
                                        <col>
                                        <col>
                                        <col>
                                        <col width="150px">
                                        <col>
                                    </colgroup>
                                    <thead>
                                    <tr>
                                        <th>名称</th>
                                        <th>编码</th>
                                        <th>类型</th>
                                        <th>创建时间</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach var="privilege" items="${list}">
                                        <c:set var="cPrivilege" value="${privilege}" scope="request"/>
                                        <jsp:include page="treeInclude.jsp"></jsp:include>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </ul>
                        </div>
                        <div id="page_content" class="page-container"></div>
                    </div>
                </div>
            </div>
        </div><!--底部-->
        <%@include file="../../include/footer.jsp"%>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">
    $(function () {
        //加载分页
          loadPageNew({elem: 'page_content', totalCount: '${page.totalCount}', limit: '${page.limit}', page: '${page.page}'});

        function initTotalCount() {
            $("#totalCount").text($("tbody tr").length);
        }

        initTotalCount();
    })

</script>
<script type="text/javascript">
    txz.initHeader({
        nav:[{
            name: '权限管理',
            curr: true
        }],
        info:'<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>',
        btns:[{
            name: '新增权限',
            href: '${ctx}/system/privilege/view.do',
            icon: 'add'
        }]
    });

    $(function () {
        layui.use(['element'], function () {
            var element = layui.element;
            element.on('tab(root)', function (data) {
                var id = $(data.elem).find(".layui-this").data("id");
                window.location.href = "${ctx}/system/privilege/list.do?parentId=" + id;
            });
        });
    })
</script>
</body>
</html>